<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

/*
|--------------------------------------------------------------------------
| 加载预定义常量
|--------------------------------------------------------------------------
*/
require_once __DIR__ . '/predefine.php';

/*
|--------------------------------------------------------------------------
| 加载自定义助手辅助函数
|--------------------------------------------------------------------------
*/
require_once __DIR__ . '/helpers.php';
require_once __DIR__ . '/ai.php';

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->validateCsrfTokens(except: [
            '/wechat/message',
        ]);

        // 注册微信浏览器检测中间件
        $middleware->alias([
            'wechat.browser' => \App\Http\Middlewares\CheckWechatBrowser::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();
